On Error GoTo MyErr

Dim OldFile, DBwithEXT, DBwithoutEXT, NewFile, CopyMyDB
'(sdata.accdb)هذا هو اسم قاععدة البيانات التي تحمل الجداول فقط قم بتغييره
OldFile = CurrentProject.Path & "\sdata.accdb"
DBwithEXT = Dir(OldFile)
DBwithoutEXT = Left(DBwithEXT, Len(DBwithEXT) - 4)

NewFile = CurrentProject.Path & "\" & "-" & Format(Date, "yyyy-mm-dd") & "-" & Format(Now(), "Hh-Nn-ss-AMPM.") & Right(DBwithEXT, 5)
CopyMyDB = "cmd.exe /C copy " & """" & OldFile & """" & " " & """" & NewFile & """"
Shell CopyMyDB, 0

MyErr:
If Err.Number <> 0 Then
MsgBox Err.Number & " - " & Err.Description
End If
MsgBox "تم عمل نسخة احتياطية من البيانات", vbInformation, "نظام سراج للمحاسبة"
